<!--客户信息列表页  ————————  客户经理可查看  -->
<template>
  <div id="CustomerInfoList">
    <!--         Breadcrumbs -->
    <div class="breadcrumbs" style="margin: 0px;padding-top: 20px;">
      <ul>
        <li class="home"><a href="index.html" title="Go to Home Page"><strong style="font-size: 18px;">客户管理</strong></a>
          <span>/</span>
        </li>
        <li><strong>客户信息管理</strong><span>/</span></li>
        <li><strong>客户信息列表</strong></li>
      </ul>
    </div>
    <article class="col-main">
      <div class="my-account block block-account" style="padding-left: 20px;padding-right: 20px;">
        <div style="padding: 20px 20px 30px 20px">
          <span style="font-size: 30px;font-weight: bolder">客户信息列表</span>
<!--          <router-link to="CreateCustomerInfo"  class="btn btn-success" style="float: right;margin-top: 10px">创建客户信息</router-link>-->
        </div>
        <table class="table">
          <thead>
          <tr>
            <th>客户编号</th>
            <th>客户名字</th>
            <th>地区</th>
            <th>等级</th>
            <th>地址</th>
            <th>电话</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <tr v-for="(item,index) in customerInfos">
            <th scope="row">{{index+1+(current-1)*limit}}</th>
            <td>{{item.customerName}}</td>
            <td>{{item.customerRegion}}</td>
            <td>{{item.customerGradeEntry}}</td>
            <td>{{item.customerAddress}}</td>
            <td>{{item.customerTel}}</td>
            <td>
              <button v-on:click="toUpdateCustomerInfo(item.customerId)" class="btn btn-primary btn-sm">修改</button>
<!--              <router-link to="UpdateCustomerInfo"></router-link>-->
              <button v-on:click="toCustomerDetailedInfo(item.customerId)" class="btn btn-default btn-sm">详情</button>
<!--              <router-link to="CustomerDetailedInfo"></router-link>-->
            </td>
          </tr>
          </tbody>
        </table>

        <div class="block text-center">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
          </el-pagination>
        </div>
      </div>
    </article>
  </div>
</template>

<script>
export default {
  name: "CustomerInfoList",
  data(){
    return{
      customerInfos:[],
      currentPage: 1,
      limit:10,
      current:1,
      total:0,
    }
  },
  methods:{
    toCustomerDetailedInfo(customerId){
      this.$router.push({path:'/MemuBar/CustomerDetailedInfo',query:{customerId:customerId}})
    },
    toUpdateCustomerInfo(customerId){
      this.$router.push({path:'/MemuBar/UpdateCustomerInfo',query:{customerId:customerId}})
    },
    loadAllCustome(){
      this.$axios.get('/customer/loadAllCustome',{
        params:{
          limit:this.limit,
          current:this.current
        }
      }).then(
        res=>{
          this.total = res.data.data.total
          this.customerInfos=res.data.data.myData
        }
      )
    },
    handleSizeChange(val) {
      this.limit = val;
      this.loadAllCustome()
    },
    handleCurrentChange(val) {
      this.current = val;
      this.loadAllCustome()
    },

  },
  created() {
    this.loadAllCustome()
  }
}
</script>

<style scoped>

</style>
